package com.cq.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cq.health.common.MessageConst;
import com.cq.health.entity.Result;
import com.cq.health.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName: health_project
 * @Package: com.cq.health.controller
 * @ClassName: UserController
 * @Author: 悠久的苍穹
 * @Description: ${description}
 * @Date: 2020/5/6 16:36
 * @Version: 1.0
 */
//都用json格式返回
@RestController
@RequestMapping("/web/user")
public class UserController {

    @Reference
    private UserService userService;

//    @ResponseBody 写了RestController后不用写
    @RequestMapping("/login")
    public Result login(String username,String password){
        try {
            if(userService.login(username,password)){
                return new Result(true, MessageConst.ACTION_SUCCESS,username);
            }
        } catch (Exception e){
            e.printStackTrace();
        }
        return new Result(false,MessageConst.ACTION_FAIL);
    }

}
